package com.wece.myapplication;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button  button = findViewById(R.id.button);
        button.setOnClickListener(this);
        Button  button2 = findViewById(R.id.button2);
        button2.setOnClickListener(this);
        EditText editText = findViewById(R.id.edit_text);
        ImageView imageView = findViewById(R.id.image_view);
        ProgressBar progressBar = findViewById(R.id.progress_bar);

        /*button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String inputTest = editText.getText().toString();
                Log.d("123","123123");
                Log.d("123",inputTest);
                Toast.makeText(MainActivity.this,inputTest,Toast.LENGTH_SHORT).show();
                imageView.setImageResource(R.drawable.bigwindcar);
                if(progressBar.getVisibility()==View.GONE){
                    progressBar.setVisibility((View.VISIBLE));
                }else{
                    progressBar.setVisibility(View.GONE);
                }
                int progress = progressBar.getProgress();
                progress += 10;
                progressBar.setProgress(progress);
            }
        });*/
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button:
                Log.d("123","button go");
                AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
                dialog.setTitle("this is a dialog");
                dialog.setCancelable(false);
                dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
                dialog.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
                dialog.show();
                break;
                case R.id.button2:
                Log.d("123","button2 go");
                ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
                progressDialog.setTitle("this is a progressDialog");
                progressDialog.setMessage("Loading....123123123");
                progressDialog.setCancelable(true);
                progressDialog.show();
                break;
            default:

                Log.d("123","no button go away");
                break;
        }

    }
}